<template>
	<view class="main">
		<view class="active_tit">
			<view class="tit">
				个人资产情况（家用汽车）
			</view> 
			<!-- <view class="add" @click="add">
				＋
			</view> -->
		</view>
		<!-- input -->
		<view v-for="(item,index) in stdOffsurCars" :key='index'>
			<view class="cut">家用车{{index+1}} <uni-icons class="clear" type="clear" @click='stdDel(stdOffsurCars,item,"stdOffsurCars")'></uni-icons></view>
			<view class="main">
				<ActiveForm required  ref=''>
					<view class="active_label">
						序号：
					</view>
					<view class="active_input">
						<input type="text" :disabled="true" v-model="item.xh" />
					</view>
				</ActiveForm>
				<ActiveForm required  ref=''>
					<view class="active_label">
						所有权人：
					</view>
					<view class="active_input">
						<input type="text" v-model="item.asssetsOwner" />
					</view>
				</ActiveForm>
				<ActiveForm required  ref=''>
					<view class="active_label">
						品牌型号：
					</view>
					<view class="active_input">
						<input type="text" v-model="item.brandType" />
					</view>
				</ActiveForm>
				<ActiveForm required  ref=''>
					<view class="active_label">
						购买时间：
					</view>
					<view class="active_input">
						<!-- <input type="text" v-model="item.buyTime" /> -->
						<picker style="width: 100%;" mode="date" :value="item.buyTime"   @change="(o)=>{item.buyTime=o.target.value}">
						    <view >{{item.buyTime}}</view>
						</picker>
					</view>
				</ActiveForm>
				<ActiveForm required  ref=''>
					<view class="active_label">
						购买价格（元）：
					</view>
					<view class="active_input">
						<mInput maxlength="16" type="number" v-model="item.price" />
					</view>
				</ActiveForm>
				<!-- <ActiveForm required  ref=''>
					<view class="active_label">
						贷款余额（元）：
					</view>
					<view class="active_input">
						<mInput maxlength="16" type="number" v-model="item.guarBalance" />
					</view>
				</ActiveForm> -->
				<ActiveForm  required  ref=''>
					<view class="active_label">
						车牌号：
					</view>
					<view class="active_input">
						<input type="text" v-model="item.carCode" />
					</view>
				</ActiveForm>
				<ActiveForm   ref=''>
					<view class="active_label">
						备注：
					</view>
					<view class="active_input">
						<input type="text" v-model="item.remark" />
					</view>
				</ActiveForm>
			</view>
		</view>
		<view class="active_tit">
			<view class="" style="display: flex;">
				<view class="add" @click="add">
					新增家用车
				</view>
			</view>
		</view>
		<ActiveForm required  ref=''>
			<view class="active_label">
				购买价格总计：
			</view>
			<view class="active_input">
				<input type="number"  :disabled="true" v-model="goumaizongjia" />
			</view>
		</ActiveForm>
		<!-- <ActiveForm required  ref=''>
			<view class="active_label">
				贷款余额总计：
			</view>
			<view class="active_input">
				<input type="number"  :disabled="true" v-model="zongjia" />
			</view>
		</ActiveForm> -->
		<!-- <button type="default" @click="getForm">getForm</button> -->
	</view>
</template>

<script>
	import SelectPicker from "../../SelectPicker";
	import RegionPicker from "../../RegionPicker";
	import region from '../areaList.js'
	export default {
		name: 'userCars',
		data() {
			return {
				region,
				province: "",
				city: "",
				county: "",
				index: 1,
				listNum:1,
				stdOffsurCars:[],
				zongjijine:'',
				zongjia:'',
				goumaizongjia:''
			}
		},
		components: {
			SelectPicker,
			RegionPicker

		},
		watch:{
			stdOffsurCars:{
				handler:function(res){
					//console.warn('userCars组件数据变化',res)
					getApp().globalData.stdOffsurCars = res
					let totalPrice = 0
					//this.zongjia = this.stdOffsurCars.reduce((totalPrice, item) => totalPrice + Number(item.guarBalance), 0)
					this.goumaizongjia = this.stdOffsurCars.reduce((totalPrice, item) => totalPrice + Number(item.price), 0)
				    getApp().globalData.total.stdOffsurCars = {
						price:this.goumaizongjia,
						guarBalance:this.zongjia,
						xh:'999'
					}
				
				},
				deep:true
			},
		},
		mounted() {
			//获取返显数据
			setTimeout(()=>{
				this.stdOffsurCars = getApp().globalData.stdOffsurCars
			},getApp().globalData.timeout)
		},
		methods:{
			add(){
				this.stdOffsurCars.push(
					{
						asssetsOwner:'',
						brandType:'',
						buyTime:'',
						price:'',
						guarBalance:'',
						carCode:'',
						xh: this.stdOffsurCars.length + 1
					}
				)
			}
		}
	}
</script>

<style lang="scss">
	
	
</style>

